package com.wbt.huawei;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * @program: Thread-demo
 * @description:
 * @author: Wang·Baotong
 * @create: 2021-03-11 09:42
 */
public class AB2C {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String str;
        /*while (( str = bf.readLine() )!=null){
            int num = Integer.parseInt(str);
            int[] data = Arrays.stream(bf.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

            for (int i=0;i<data.length-1;i++){
                for (int j=i+1;j<data.length;j++){
                    int a =data[i] + 2 * data[j];
                    if(Arrays.asList(data).contains(a)){

                    }

                }
            }



            Arrays.asList(data);

        }*/

        String[] a = {"a", "b", "c", "d"};
        combinationSelect(a,3);


    }

    public static void combinationSelect(String[] dataList, int n) {
        //System.out.println(String.format("C(%d, %d) = %d", dataList.length, n, combination(n, dataList.length)));
        combinationSelect(dataList, 0, new String[n], 0);
    }

    private static void combinationSelect(String[] dataList, int dataIndex, String[] resultList, int resultIndex) {
        int resultLen = resultList.length;
        int resultCount = resultIndex + 1;
        if (resultCount > resultLen) { // 全部选择完时，输出组合结果
            System.out.println(Arrays.asList(resultList));
            return;
        }
        // 递归选择下一个
        for (int i = dataIndex; i < dataList.length + resultCount - resultLen; i++) {
            resultList[resultIndex] = dataList[i];
            combinationSelect(dataList, i + 1, resultList, resultIndex + 1);
        }
    }
}
